<@ macro typeList(types) -@>
  <@ set separator = joiner("|") @>
  <@ for type in types @><$ separator() $><$ type | code $><@ endfor @>
<@- endmacro -@>

<@ macro paramTable(params, isDirective) @>
<table class="table" style="margin:0;">
  <thead>
    <tr>
      <th><@ if isDirective @>Attr<@ else @>Param<@ endif @></th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    <@ for param in params @>
    <tr>
      <td>
        <$ param.name $>
        <@ if param.alias @>| <$ param.alias $><@ endif @>
        <@ if param.type.optional @><div><em>(optional)</em></div><@ endif @>
      </td>
      <td>
        <$ typeList(param.typeList) $>
      </td>
      <td>
        <$ param.description | marked $>
        <@ if param.default @><p><em>(default: <$ param.default $>)</em></p><@ endif @>
      </td>
    </tr>
    <@ endfor @>
  </tbody>
</table>
<@ endmacro @>


<@- macro directiveParam(name, type, join, sep) @>
  <@- if type.optional @>[<@ endif -@>
  <$ name | dashCase $><$ join $><$ type.description $><$ sep $>
  <@- if type.optional @>]<@ endif -@>
<@ endmacro -@>

<@- macro functionSyntax(fn) @>
<@- set sep = joiner(', ') -@>
<code><$ fn.name $>(<@- for param in fn.params @><$ sep() $>
  <@- if param.type.optional @>[<@ endif -@>
  <$ param.name $>
  <@- if param.type.optional @>]<@ endif -@>
  <@ endfor @>)</code><@ if fn.alias @><small>(alias: <$ fn.alias $>)</small><@ endif @>
<@ endmacro -@>

<@- macro typeInfo(fn) -@>
<$ typeList(fn.typeList) $> <$ fn.description $>
<@- endmacro -@>
